package com.xianyu.admin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
/**
* Knife4j配置
* 作者:羡鱼  
* qq:642133706
* 当前时间 2024/9/1 15:53
*/
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {
    @Bean
    public Docket adminApiConfig() {
        Docket adminApi = new Docket(DocumentationType.SWAGGER_2)
                .groupName("羡鱼系统API接口文档")
                .apiInfo(adminApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.xianyu.admin.common"))//为当前包路径下,所有API都交给Swagger2管理
                .build();
        return adminApi;
    }

    //本地访问  http://localhost:8000/doc.html
    private ApiInfo adminApiInfo() {
        return new ApiInfoBuilder()
                .title("羡鱼系统API接口文档")
                .license("羡鱼")
                .description("羡鱼系统API接口说明")
                .version("1.0.0")//版本号
                .build();
    }
}
